package com.dobbinsoft.iotechn.user.api.open;

import com.dobbinsoft.iotechn.core.annotation.*;
import com.dobbinsoft.iotechn.core.annotation.param.NotNull;
import com.dobbinsoft.iotechn.core.annotation.param.TextFormat;
import com.dobbinsoft.iotechn.core.constant.Const;
import com.dobbinsoft.iotechn.core.exception.ServiceException;
import com.dobbinsoft.iotechn.core.model.DeveloperSession;
import com.dobbinsoft.iotechn.user.dto.DeveloperDTO;
import com.dobbinsoft.iotechn.user.dto.VerifyCodeDTO;

/**
 * Description: 开发者用户服务
 * User: rize
 * Date: 2020/6/7
 * Time: 15:45
 */
@HttpOpenApi(group = "developer", description = "开发者服务")
public interface DeveloperService {

    @HttpMethod(description = "获取验证码", rate = 180, rateLimitDurationInSec = 60, rateLimit = RateLimitType.IP)
    public VerifyCodeDTO getVerifyCode() throws ServiceException;

    @HttpMethod(description = "登录", rate = 120, rateLimitDurationInSec = 60, rateLimit = RateLimitType.IP)
    public DeveloperDTO login(
            @NotNull @HttpParam(name = "phone", type = HttpParamType.COMMON, description = "手机号") String phone,
            @NotNull @TextFormat(lengthMin = 8, notChinese = true, lengthMax = 32) @HttpParam(name = "password", type = HttpParamType.COMMON, description = "密码") String password,
            @NotNull @HttpParam(name = "verifyCode", type = HttpParamType.COMMON, description = "验证码") String verifyCode,
            @NotNull @HttpParam(name = "uuid", type = HttpParamType.COMMON, description = "UUID") String uuid,
            @NotNull @HttpParam(name = "ip", type = HttpParamType.IP, description = "ip地址") String ip) throws ServiceException;

    @HttpMethod(description = "注册", rate = 60, rateLimitDurationInSec = 60, rateLimit = RateLimitType.IP)
    public DeveloperDTO register(
            @NotNull @HttpParam(name = "phone", type = HttpParamType.COMMON, description = "手机号") String phone,
            @NotNull @TextFormat(lengthMin = 8, notChinese = true, lengthMax = 32) @HttpParam(name = "password", type = HttpParamType.COMMON, description = "密码") String password,
            @NotNull @HttpParam(name = "smsVerifyCode", type = HttpParamType.COMMON, description = "验证码") String smsVerifyCode,
            @NotNull @HttpParam(name = "ip", type = HttpParamType.IP, description = "ip地址") String ip) throws ServiceException;

    @HttpMethod(description = "发送验证码到用户手机", rate = 60, rateLimitDurationInSec = 60, rateLimit = RateLimitType.IP)
    public String sendSmsVerifyCode(
            @NotNull @HttpParam(name = "phone", type = HttpParamType.COMMON, description = "用户手机号") String phone) throws ServiceException;

    @HttpMethod(description = "找回密码", rate = 60, rateLimitDurationInSec = 60, rateLimit = RateLimitType.IP)
    public String findPassword(
            @NotNull @HttpParam(name = "phone", type = HttpParamType.COMMON, description = "手机号") String phone,
            @NotNull @TextFormat(lengthMin = 8, notChinese = true, lengthMax = 32) @HttpParam(name = "password", type = HttpParamType.COMMON, description = "密码") String password,
            @NotNull @HttpParam(name = "smsVerifyCode", type = HttpParamType.COMMON, description = "验证码") String smsVerifyCode,
            @NotNull @HttpParam(name = "ip", type = HttpParamType.IP, description = "ip地址") String ip) throws ServiceException;

    @HttpMethod(description = "退登")
    public String logout(
            @NotNull @HttpParam(name = Const.DEVELOPER_ACCESS_TOKEN, type = HttpParamType.HEADER, description = "令牌") String accessToken) throws ServiceException;

    @HttpMethod(description = "信息")
    public DeveloperSession info(
            @NotNull @HttpParam(name = "developerId", type = HttpParamType.DEVELOPER_ID, description = "开发者Id") Long developerId) throws ServiceException;

}
